package cc.rengu.igas.channel.upqc.biz.impl;

import cc.rengu.igas.channel.upqc.common.constant.UpqcServiceConstant;
import cc.rengu.igas.channel.upqc.common.enums.RespCodeEnum;
import cc.rengu.igas.channel.upqc.facade.UpqcService;
import cc.rengu.igas.channel.upqc.facade.request.*;
import cc.rengu.igas.channel.upqc.facade.response.*;
import cc.rengu.igas.channel.upqc.facade.result.Result;
import cc.rengu.oltp.service.model.BizException;
import cc.rengu.oltp.service.model.DubboResult;
import cc.rengu.oltp.service.realize.DubboService;
import cc.rengu.oltp.service.realize.impl.DubboServiceImpl;
import cc.rengu.utility.log.RgLog;
import cc.rengu.utility.log.RgLogger;

import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;

public class UpqcServiceImpl implements UpqcService {
    private RgLogger rglog = RgLog.getLogger(this.getClass().getName());

    @Override
    public Result<C2BConsumeResponse> c2bConsume(C2BConsumeRequest c2BConsumeRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<C2BConsumeResponse> result = new Result<>();
        C2BConsumeResponse c2BConsumeResponse = new C2BConsumeResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(c2BConsumeRequest,
                    UpqcServiceConstant.C2BCONSUME_SERVICE, C2BConsumeResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((C2BConsumeResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("被扫消费失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                c2BConsumeResponse.setRespDesc(((BizException) e).getCode());
                c2BConsumeResponse.setRespDesc(e.getMessage());
            } else {
                c2BConsumeResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                c2BConsumeResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<C2BConsumeRevsalResponse> c2bConsumeRevsal(C2BConsumeRevsalRequest c2BConsumeRevsalRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<C2BConsumeRevsalResponse> result = new Result<>();
        C2BConsumeRevsalResponse c2BConsumeRevsalResponse = new C2BConsumeRevsalResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(c2BConsumeRevsalRequest,
                    UpqcServiceConstant.C2BCONSUME_REVSAL_SERVICE, C2BConsumeRevsalResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((C2BConsumeRevsalResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("被扫消费冲正失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                c2BConsumeRevsalResponse.setRespDesc(((BizException) e).getCode());
                c2BConsumeRevsalResponse.setRespDesc(e.getMessage());
            } else {
                c2BConsumeRevsalResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                c2BConsumeRevsalResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<C2BConsumeCancelResponse> c2bConsumeCancel(C2BConsumeCancelRequest c2BConsumeCancelRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<C2BConsumeCancelResponse> result = new Result<>();
        C2BConsumeCancelResponse c2BConsumeCancelResponse = new C2BConsumeCancelResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(c2BConsumeCancelRequest,
                    UpqcServiceConstant.C2BCONSUME_CANCEL_SERVICE, C2BConsumeCancelResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((C2BConsumeCancelResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("被扫撤销失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                c2BConsumeCancelResponse.setRespDesc(((BizException) e).getCode());
                c2BConsumeCancelResponse.setRespDesc(e.getMessage());
            } else {
                c2BConsumeCancelResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                c2BConsumeCancelResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<C2BConsumeRefundResponse> c2bConsumeRefund(C2BConsumeRefundRequest c2BConsumeRefundRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<C2BConsumeRefundResponse> result = new Result<>();
        C2BConsumeRefundResponse c2BConsumeRefundResponse = new C2BConsumeRefundResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(c2BConsumeRefundRequest,
                    UpqcServiceConstant.C2BCONSUME_REFUND_SERVICE, C2BConsumeRefundResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((C2BConsumeRefundResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("被扫消费退款失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                c2BConsumeRefundResponse.setRespDesc(((BizException) e).getCode());
                c2BConsumeRefundResponse.setRespDesc(e.getMessage());
            } else {
                c2BConsumeRefundResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                c2BConsumeRefundResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<C2BTranStateQueryResponse> c2bTransStateQuery(C2BTranStateQueryRequest c2BTranStateQueryRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<C2BTranStateQueryResponse> result = new Result<>();
        C2BTranStateQueryResponse tranStateQueryResponse = new C2BTranStateQueryResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(c2BTranStateQueryRequest,
                    UpqcServiceConstant.TRANS_STATE_QUERY_SERVICE, C2BTranStateQueryResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((C2BTranStateQueryResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("交易状态查询失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                tranStateQueryResponse.setRespDesc(((BizException) e).getCode());
                tranStateQueryResponse.setRespDesc(e.getMessage());
            } else {
                tranStateQueryResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                tranStateQueryResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }


    @Override
    public Result<C2BPreAuthResponse> c2bPreAuth(C2BPreAuthRequest c2BPreAuthRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<C2BPreAuthResponse> result = new Result<>();
        C2BPreAuthResponse c2BPreAuthResponse = new C2BPreAuthResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(c2BPreAuthRequest,
                    UpqcServiceConstant.C2BPREAUTH_SERVICE, C2BPreAuthResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((C2BPreAuthResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("被扫预授权失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                c2BPreAuthResponse.setRespDesc(((BizException) e).getCode());
                c2BPreAuthResponse.setRespDesc(e.getMessage());
            } else {
                c2BPreAuthResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                c2BPreAuthResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<C2BPreAuthRevsalResponse> c2bPreAuthRevsal(C2BPreAuthRevsalRequest c2BPreAuthRevsalRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<C2BPreAuthRevsalResponse> result = new Result<>();
        C2BPreAuthRevsalResponse c2BPreAuthRevsalResponse = new C2BPreAuthRevsalResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(c2BPreAuthRevsalRequest,
                    UpqcServiceConstant.C2BPREAUTH_REVSAL_SERVICE, C2BPreAuthRevsalResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((C2BPreAuthRevsalResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("被扫预授权冲正失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                c2BPreAuthRevsalResponse.setRespDesc(((BizException) e).getCode());
                c2BPreAuthRevsalResponse.setRespDesc(e.getMessage());
            } else {
                c2BPreAuthRevsalResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                c2BPreAuthRevsalResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<C2BPreAuthCancelResponse> c2bPreAuthCancel(C2BPreAuthCancelRequest c2BPreAuthCancelRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<C2BPreAuthCancelResponse> result = new Result<>();
        C2BPreAuthCancelResponse c2BPreAuthCancelResponse = new C2BPreAuthCancelResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(c2BPreAuthCancelRequest,
                    UpqcServiceConstant.C2BPREAUTH_CANCEL_SERVICE, C2BPreAuthCancelResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((C2BPreAuthCancelResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("被扫预授权撤销失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                c2BPreAuthCancelResponse.setRespDesc(((BizException) e).getCode());
                c2BPreAuthCancelResponse.setRespDesc(e.getMessage());
            } else {
                c2BPreAuthCancelResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                c2BPreAuthCancelResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<C2BPreAuthFinishResponse> c2bPreAuthFinish(C2BPreAuthFinishRequest c2BPreAuthFinishRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<C2BPreAuthFinishResponse> result = new Result<>();
        C2BPreAuthFinishResponse c2BPreAuthFinishResponse = new C2BPreAuthFinishResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(c2BPreAuthFinishRequest,
                    UpqcServiceConstant.C2BPREAUTH_FINISH_SERVICE, C2BPreAuthFinishResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((C2BPreAuthFinishResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("被扫预授权完成失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                c2BPreAuthFinishResponse.setRespDesc(((BizException) e).getCode());
                c2BPreAuthFinishResponse.setRespDesc(e.getMessage());
            } else {
                c2BPreAuthFinishResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                c2BPreAuthFinishResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<C2BPreAuthFinishRevsalResponse> c2bPreAuthFinishRevsal(C2BPreAuthFinishRevsalRequest c2BPreAuthFinishRevsalRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<C2BPreAuthFinishRevsalResponse> result = new Result<>();
        C2BPreAuthFinishRevsalResponse c2BPreAuthFinishRevsalResponse = new C2BPreAuthFinishRevsalResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(c2BPreAuthFinishRevsalRequest,
                    UpqcServiceConstant.C2BPREAUTH_FINISH_RELSAL_SERVICE, C2BPreAuthFinishRevsalResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((C2BPreAuthFinishRevsalResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("预授权完成冲正失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                c2BPreAuthFinishRevsalResponse.setRespDesc(((BizException) e).getCode());
                c2BPreAuthFinishRevsalResponse.setRespDesc(e.getMessage());
            } else {
                c2BPreAuthFinishRevsalResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                c2BPreAuthFinishRevsalResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<C2BPreAuthFinishCancelResponse> c2bPreAuthFinishCancel(C2BPreAuthFinishCancelRequest c2BPreAuthFinishCancelRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<C2BPreAuthFinishCancelResponse> result = new Result<>();
        C2BPreAuthFinishCancelResponse c2BPreAuthFinishCancelResponse = new C2BPreAuthFinishCancelResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(c2BPreAuthFinishCancelRequest,
                    UpqcServiceConstant.C2BPREAUTH_FINISH_CANCEL_SERVICE, C2BPreAuthFinishCancelResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((C2BPreAuthFinishCancelResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("被扫预授权完成撤销失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                c2BPreAuthFinishCancelResponse.setRespDesc(((BizException) e).getCode());
                c2BPreAuthFinishCancelResponse.setRespDesc(e.getMessage());
            } else {
                c2BPreAuthFinishCancelResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                c2BPreAuthFinishCancelResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<GenQrCodeResponse> genQrCode(GenQrCodeRequest genQrCodeRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<GenQrCodeResponse> result = new Result<>();
        GenQrCodeResponse genQrCodeResponse = new GenQrCodeResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(genQrCodeRequest,
                    UpqcServiceConstant.GEN_QRCODE_SERVICE, GenQrCodeResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((GenQrCodeResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("生成二维码失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                genQrCodeResponse.setRespDesc(((BizException) e).getCode());
                genQrCodeResponse.setRespDesc(e.getMessage());
            } else {
                genQrCodeResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                genQrCodeResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<B2CTranStateQueryResponse> b2cTransStateQuery(B2CTranStateQueryRequest b2CTranStateQueryRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<B2CTranStateQueryResponse> result = new Result<>();
        B2CTranStateQueryResponse b2CTranStateQueryResponse = new B2CTranStateQueryResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(b2CTranStateQueryRequest,
                    UpqcServiceConstant.B2CTRANS_STATE_QUERY_SERVICE, B2CTranStateQueryResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((B2CTranStateQueryResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("收款查询失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                b2CTranStateQueryResponse.setRespDesc(((BizException) e).getCode());
                b2CTranStateQueryResponse.setRespDesc(e.getMessage());
            } else {
                b2CTranStateQueryResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                b2CTranStateQueryResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<B2CConsumeCancelResponse> b2cConsumeCancel(B2CConsumeCancelRequest b2CConsumeCancelRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<B2CConsumeCancelResponse> result = new Result<>();
        B2CConsumeCancelResponse b2CConsumeCancelResponse = new B2CConsumeCancelResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(b2CConsumeCancelRequest,
                    UpqcServiceConstant.B2CCONSUME_CANCEL_SERVICE, B2CConsumeCancelResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((B2CConsumeCancelResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("主扫消费撤销失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                b2CConsumeCancelResponse.setRespDesc(((BizException) e).getCode());
                b2CConsumeCancelResponse.setRespDesc(e.getMessage());
            } else {
                b2CConsumeCancelResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                b2CConsumeCancelResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<QrCodeCancelResponse> qrcodeCancel(QrCodeCancelRequest qrCodeCancelRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<QrCodeCancelResponse> result = new Result<>();
        QrCodeCancelResponse qrCodeCancelResponse = new QrCodeCancelResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(qrCodeCancelRequest,
                    UpqcServiceConstant.QRCODE_CANCEL_SERVICE, QrCodeCancelResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((QrCodeCancelResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("撤销二维码失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                qrCodeCancelResponse.setRespDesc(((BizException) e).getCode());
                qrCodeCancelResponse.setRespDesc(e.getMessage());
            } else {
                qrCodeCancelResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                qrCodeCancelResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<B2CConsumeRefundResponse> b2cConsumeRefund(B2CConsumeRefundRequest b2CConsumeRefundRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<B2CConsumeRefundResponse> result = new Result<>();
        B2CConsumeRefundResponse b2CConsumeRefundResponse = new B2CConsumeRefundResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(b2CConsumeRefundRequest,
                    UpqcServiceConstant.C2BCONSUME_REFUND_SERVICE, B2CConsumeRefundResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((B2CConsumeRefundResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("退款失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                b2CConsumeRefundResponse.setRespDesc(((BizException) e).getCode());
                b2CConsumeRefundResponse.setRespDesc(e.getMessage());
            } else {
                b2CConsumeRefundResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                b2CConsumeRefundResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

}
